<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>watch</title>
</head>
<body>
  <div id="app">
    {{user.fullName}}
  </div>
  <script src="../vue/vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        user: {
          firstName: '刘',
          lastName: '备',
          fullName: ''
        }
      }
    })

    vm.$watch('user', function (newVal, oldVal) {
      this.user.fullName = newVal.firstName + ' ' + newVal.lastName
    }, {
      immediate: true,
      deep: true,
    })
    // console.log(vm)
  </script>
</body>
</html>
